xiongzhu 2 лет назад
Родитель
Сommit
8831b1b63c

+ 3 - 1
.gitignore

@@ -34,4 +34,6 @@ build/
 dump.sql
 build.tar.gz
 
-/upload
+/upload
+
+node_modules

+ 0 - 65
.idea/$CACHE_FILE$

@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectInspectionProfilesVisibleTreeState">
-    <entry key="Project Default">
-      <profile-state>
-        <expanded-state>
-          <State />
-          <State>
-            <id>Class structureJava</id>
-          </State>
-          <State>
-            <id>Code maturityJava</id>
-          </State>
-          <State>
-            <id>Google Web Toolkit</id>
-          </State>
-          <State>
-            <id>JUnitJava</id>
-          </State>
-          <State>
-            <id>Java</id>
-          </State>
-          <State>
-            <id>Java 5Java language level migration aidsJava</id>
-          </State>
-          <State>
-            <id>Java 7Java language level migration aidsJava</id>
-          </State>
-          <State>
-            <id>Java 8Java language level migration aidsJava</id>
-          </State>
-          <State>
-            <id>Java language level migration aidsJava</id>
-          </State>
-          <State>
-            <id>JavadocJava</id>
-          </State>
-          <State>
-            <id>Numeric issuesJava</id>
-          </State>
-          <State>
-            <id>PerformanceJava</id>
-          </State>
-          <State>
-            <id>Spring</id>
-          </State>
-          <State>
-            <id>Spring AOPSpring</id>
-          </State>
-          <State>
-            <id>TestNGJava</id>
-          </State>
-          <State>
-            <id>Threading issuesJava</id>
-          </State>
-        </expanded-state>
-        <selected-state>
-          <State>
-            <id>Android</id>
-          </State>
-        </selected-state>
-      </profile-state>
-    </entry>
-  </component>
-</project>

+ 0 - 27
.idea/compiler.xml

@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="CompilerConfiguration">
-    <annotationProcessing>
-      <profile default="true" name="Default" enabled="true" />
-      <profile name="Maven default annotation processors profile" enabled="true">
-        <sourceOutputDir name="target/generated-sources/annotations" />
-        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
-        <outputRelativeToContentRoot value="true" />
-        <module name="baixiaip" />
-        <module name="yzzscq" />
-      </profile>
-    </annotationProcessing>
-    <bytecodeTargetLevel>
-      <module name="baixiaip" target="11" />
-      <module name="yzzscq" target="11" />
-      <module name="yzzscy" target="17" />
-    </bytecodeTargetLevel>
-  </component>
-  <component name="JavacSettings">
-    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
-      <module name="baixiaip" options="-parameters" />
-      <module name="yzzscq" options="-parameters" />
-      <module name="yzzscy" options="-parameters" />
-    </option>
-  </component>
-</project>

+ 0 - 6
.idea/encodings.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="Encoding">
-    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
-  </component>
-</project>

+ 0 - 36
.idea/inspectionProfiles/Project_Default.xml

@@ -1,36 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <profile version="1.0">
-    <option name="myName" value="Project Default" />
-    <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
-      <option name="TOP_LEVEL_CLASS_OPTIONS">
-        <value>
-          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
-          <option name="REQUIRED_TAGS" value="" />
-        </value>
-      </option>
-      <option name="INNER_CLASS_OPTIONS">
-        <value>
-          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
-          <option name="REQUIRED_TAGS" value="" />
-        </value>
-      </option>
-      <option name="METHOD_OPTIONS">
-        <value>
-          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
-          <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
-        </value>
-      </option>
-      <option name="FIELD_OPTIONS">
-        <value>
-          <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
-          <option name="REQUIRED_TAGS" value="" />
-        </value>
-      </option>
-      <option name="IGNORE_DEPRECATED" value="false" />
-      <option name="IGNORE_JAVADOC_PERIOD" value="true" />
-      <option name="IGNORE_DUPLICATED_THROWS" value="false" />
-      <option name="IGNORE_POINT_TO_ITSELF" value="false" />
-      <option name="myAdditionalJavadocTags" value="date" />
-    </inspection_tool>
-  </profile>
-</component>

+ 0 - 35
.idea/jarRepositories.xml

@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="RemoteRepositoriesConfiguration">
-    <remote-repository>
-      <option name="id" value="Local repository" />
-      <option name="name" value="Local repository" />
-      <option name="url" value="file://C:\Users\13077\Desktop\yzzscq/libs" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://repo.maven.apache.org/maven2" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="jitpack.io" />
-      <option name="name" value="jitpack.io" />
-      <option name="url" value="https://jitpack.io" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="nexus-aliyun" />
-      <option name="name" value="nexus-aliyun" />
-      <option name="url" value="https://maven.aliyun.com/repository/central" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Maven Central repository" />
-      <option name="url" value="https://repo1.maven.org/maven2" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="jboss.community" />
-      <option name="name" value="JBoss Community repository" />
-      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
-    </remote-repository>
-  </component>
-</project>

+ 0 - 13
.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml

@@ -1,13 +0,0 @@
-<component name="libraryTable">
-  <library name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

+ 0 - 13
.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml

@@ -1,13 +0,0 @@
-<component name="libraryTable">
-  <library name="Maven: org.hamcrest:hamcrest:2.2">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/2.2/hamcrest-2.2-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest/2.2/hamcrest-2.2-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

+ 0 - 13
.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml

@@ -1,13 +0,0 @@
-<component name="libraryTable">
-  <library name="Maven: org.opentest4j:opentest4j:1.2.0">
-    <CLASSES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
-    </CLASSES>
-    <JAVADOC>
-      <root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-javadoc.jar!/" />
-    </JAVADOC>
-    <SOURCES>
-      <root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>

+ 0 - 16
.idea/misc.xml

@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="JavaScriptSettings">
-    <option name="languageLevel" value="ES6" />
-  </component>
-  <component name="MavenProjectsManager">
-    <option name="originalFiles">
-      <list>
-        <option value="$PROJECT_DIR$/pom.xml" />
-      </list>
-    </option>
-  </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
-    <output url="file://$PROJECT_DIR$/out" />
-  </component>
-</project>

+ 0 - 6
.idea/vcs.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="VcsDirectoryMappings">
-    <mapping directory="" vcs="Git" />
-  </component>
-</project>

BIN
lib/EOS S3 Java SDK STS.jar


BIN
lib/EOS S3 Java SDK.jar


+ 25 - 0
pom.xml

@@ -46,6 +46,18 @@
         </plugins>
     </build>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>software.amazon.awssdk</groupId>
+                <artifactId>bom</artifactId>
+                <version>2.17.100</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
     <dependencies>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -297,6 +309,19 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>s3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>kms</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>software.amazon.awssdk</groupId>
+            <artifactId>s3control</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 83 - 0
src/main/java/com/izouma/zhirongip/service/storage/EosStorageService.java

@@ -0,0 +1,83 @@
+package com.izouma.zhirongip.service.storage;
+
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.izouma.zhirongip.exception.BusinessException;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.stereotype.Service;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.core.sync.RequestBody;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.PutObjectRequest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+@Data
+@Service
+@Slf4j
+@EnableConfigurationProperties
+@ConditionalOnProperty(name = "storage.provider", havingValue = "eos")
+public class EosStorageService implements StorageService {
+
+    @Override
+    public String uploadFromInputStream(InputStream inputStream, String path) {
+        log.info("EOS上传: inputStream -> {}", path);
+        try {
+            String result = upload(inputStream, path);
+            log.info("上传成功 {}", result);
+            return result;
+        } catch (Exception e) {
+            log.error("EOS上传失败", e);
+            throw new BusinessException("上传失败", e.getMessage());
+        }
+    }
+
+    @Override
+    public String uploadFromUrl(String url, String path) {
+        log.info("EOS上传: {} -> {}", url, path);
+        try {
+            InputStream inputStream = new URL(url).openStream();
+            String result = upload(inputStream, path);
+            log.info("上传成功 {}", result);
+            return result;
+        } catch (Exception e) {
+            log.error("EOS上传失败", e);
+            throw new BusinessException("上传失败", e.getMessage());
+        }
+    }
+
+    private String upload(InputStream inputStream, String path) throws IOException {
+        S3Client client = S3Client.builder()
+                                  .credentialsProvider(() -> new AwsCredentials() {
+                                      @Override
+                                      public String accessKeyId() {
+                                          return "WI5C4BHR0HWYFIGP2I7Z";
+                                      }
+
+                                      @Override
+                                      public String secretAccessKey() {
+                                          return "e0a82e65ae784d83af6997a774f88375";
+                                      }
+                                  })
+                                  .endpointOverride(URI.create("https://eos-fujian-1.cmecloud.cn"))
+                                  .region(Region.of("fujian1"))
+                                  .build();
+        PutObjectRequest objectRequest = PutObjectRequest.builder()
+                                                         .bucket("yzip")
+                                                         .key(path)
+                                                         .build();
+        client.putObject(objectRequest, RequestBody.fromInputStream(inputStream, inputStream.available()));
+
+        return "https://yzip.eos-fujian-1.cmecloud.cn" + "/" + path;
+    }
+
+}

+ 4 - 3
src/main/resources/application.yaml

@@ -86,11 +86,12 @@ general:
 
 spring:
     profiles: test
-    url: jdbc:mysql://mysql.izouma.com/yangzhou_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
 
 ---
 
 spring:
     profiles: prod
-    url: jdbc:mysql://mysql.izouma.com/yangzhou_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
-
+    datasource:
+        url: jdbc:mysql://100.113.204.123/yzip?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
+        username: yzip
+        password: w@xaZLAk%M4@*J

+ 1 - 2
src/main/vue/.prettierrc.js

@@ -17,6 +17,5 @@ module.exports = {
                 parser: 'vue'
             }
         }
-    ],
-    endOfLine: 'crlf'
+    ]
 };

+ 10 - 13
src/main/vue/src/area.js

@@ -553,17 +553,14 @@
 // ];
 
 export default [
-    { label: '南京市', value: '南京市' },
-    { label: '无锡市', value: '无锡市' },
-    { label: '徐州市', value: '徐州市' },
-    { label: '常州市', value: '常州市' },
-    { label: '苏州市', value: '苏州市' },
-    { label: '南通市', value: '南通市' },
-    { label: '连云港市', value: '连云港市' },
-    { label: '淮安市', value: '淮安市' },
-    { label: '盐城市', value: '盐城市' },
-    { label: '扬州市', value: '扬州市' },
-    { label: '镇江市', value: '镇江市' },
-    { label: '泰州市', value: '泰州市' },
-    { label: '宿迁市', value: '宿迁市' }
+    { label: '广陵区', value: '广陵区' },
+    { label: '邗江区', value: '邗江区' },
+    { label: '江都区', value: '江都区' },
+    { label: '开发区', value: '开发区' },
+    { label: '生态科技新城', value: '生态科技新城' },
+    { label: '化工园区', value: '化工园区' },
+    { label: '仪征市', value: '仪征市' },
+    { label: '高邮市', value: '高邮市' },
+    { label: '宝应县', value: '宝应县' },
+    { label: '其他地区', value: '其他地区' }
 ];

+ 22 - 0
src/test/java/com/izouma/zhirongip/service/storage/EosStorageServiceTest.java

@@ -0,0 +1,22 @@
+package com.izouma.zhirongip.service.storage;
+
+import com.izouma.zhirongip.ApplicationTests;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EosStorageServiceTest extends ApplicationTests {
+    @Autowired
+    private EosStorageService eosStorageService;
+
+    @Test
+    public void upload() throws FileNotFoundException {
+        eosStorageService.uploadFromInputStream(new FileInputStream(new File("/Users/drew/Downloads/扬州知产企业(1).xlsx")), "files/1.excel");
+    }
+
+}